/*
 * Copyright (c) 2025 Industrial Software Feature Database
 */
package com.comac.ins.isfd.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.comac.ins.common.core.domain.R;
import com.comac.ins.common.idempotent.annotation.RepeatSubmit;
import com.comac.ins.common.log.annotation.Log;
import com.comac.ins.common.log.enums.BusinessType;
import com.comac.ins.common.web.core.BaseController;
import com.comac.ins.isfd.domain.bo.IsfdDatasourceTaskSchedulingConfigActionBo;
import com.comac.ins.isfd.service.IIsfdDatasourceTaskSchedulingConfigService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 数据源数据集成-任务调度配置
 *
 * @author hxloongs
 * @date 2024-10-11
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/isfd/datasourceTaskSchedulingConfig")
public class IsfdDatasourceTaskSchedulingConfigController extends BaseController {

    @Autowired
    private IIsfdDatasourceTaskSchedulingConfigService isfdDatasourceTaskSchedulingConfigService;

    /**
     * 中止接口
     */
    @SaCheckPermission("isfd:datasourceTaskSchedulingConfig:suspend")
    @Log(title = "中止接口", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PostMapping("/suspend")
    public R<Void> suspend(@RequestBody IsfdDatasourceTaskSchedulingConfigActionBo actionBo) {
        return toAjax(isfdDatasourceTaskSchedulingConfigService.suspend(actionBo));
    }

    /**
     * 任务触发接口
     */
    @SaCheckPermission("isfd:datasourceTaskSchedulingConfig:trigger")
    @Log(title = "任务触发接口", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PostMapping("/trigger")
    public R<Void> trigger(@RequestBody IsfdDatasourceTaskSchedulingConfigActionBo actionBo) {
        actionBo.setNeedSync(Boolean.TRUE);
        return toAjax(isfdDatasourceTaskSchedulingConfigService.trigger(actionBo));
    }

}
